package com.mqz.zebraEcommerce.common.valid;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class SortConstraintValidator implements ConstraintValidator<SortValidate, Integer> {
    private String regexp;

    @Override
    public void initialize(SortValidate constraintAnnotation) {
        regexp = constraintAnnotation.regexp();
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {

        return value.toString().matches(regexp);
    }
}
